package cn.liontalk.CompositePattern.normal.touming;

import java.util.ArrayList;

public class Leader3 extends Employee3 {

    public Leader3(String name) {
        this.setName(name);
        this.setEmployees(new ArrayList<>());
    }

    @Override
    public void add(Employee3 employee3) {
        this.getEmployees().add(employee3);
    }

    @Override
    public void remove(Employee3 employee3) {
        this.getEmployees().remove(employee3);
    }

    @Override
    public void display(int index) {
        for (int i = 0; i < index; i++) {
            System.out.print("----");
        }
        System.out.println("领导：" + this.getName());
        this.getEmployees().forEach(employee -> {
            employee.display(index + 1);
        });
    }
}
